import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import 'normalize.css' // 重置样式表
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import qs from 'qs'
import axios from "@/utils/axios"
Vue.use(ElementUI)

Vue.prototype.$message = ElementUI.Message;
Vue.prototype.$qs = qs;
Vue.prototype.$get = axios.get;
Vue.prototype.$post = axios.post;
Vue.prototype.$del = axios.del;
Vue.prototype.$put = axios.put;
Vue.prototype.$api = "http://localhost:7397/game" //"http://jun.liguoy.com/game"

// 阻止启动生产消息
Vue.config.productionTip = false
//登录动态背景
import VueParticles from 'vue-particles'
Vue.use(VueParticles)

//echarts
import * as echarts from 'echarts'

function get(el) {
	return document.querySelector(el);
}

function init(el, options) {
	if (!echarts) return;
	let data = echarts.init(get(el));
	data.setOption(options);
	window.addEventListener("resize", function() {
		data.resize();
	});
}

Vue.prototype.$echarts = init
//encharts end

// 连点
Vue.directive('throttle', {
  inserted(el, binding) {
    el.addEventListener('click', () => {
      el.style.pointerEvents = 'none'
      if (!el.disabled) {
        setTimeout(() => {
          el.style.pointerEvents = 'auto'
        }, binding.value || 2000)
      }
    })
  }
})

new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
